/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Namespace;


import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionContext;
import database.CustomerDAO;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import model.Customer;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Trang
 */
@Namespace("/Administration/Customer")
public class WCustomeManagerAction extends ActionSupport{
    private List<Customer> customers = new ArrayList<Customer>();
    private CustomerDAO authenDAO = new CustomerDAO();
    private Map<Integer, String> sorts;
    private Integer sort;
    
     public Map<Integer, String> getSorts() {
        return sorts;
    }

    public void setSorts(Map<Integer, String> sorts) {
        this.sorts = sorts;
    }

   

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public WCustomeManagerAction()
    {
        sorts = new HashMap<Integer, String>();
        sorts.put(1, "First Name");
        sorts.put(2, "Last Name");
        sorts.put(3, "Address");
        sorts.put(4, "DOB");
    }
    public List<Customer> getCustomers() {
        return customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }
     @Action(value= "customer-management", results = {
	@Result(name ="success",location="/manageCustomer/w_customer.jsp")
    })
    public String CustomerManagement()
    { 
        Map session = ActionContext.getContext().getSession();
                session.put("customer", 1);
//        setCustomers(authenDAO.getAllCustomer());
//        List<Customer> temp;
        customers = authenDAO.getAllCustomer();    
        return SUCCESS;
    }
}
